%% Copyright
-module(tag_handler).
-author("").

%% API
-export([init/3, allowed_methods/2, content_types_provided/2]).
-export([get_tags/2]).

init(_Transport, _Req, []) ->
  {upgrade, protocol, cowboy_rest}.

allowed_methods(Req, State) ->
  {[<<"GET">>], Req, State}.

content_types_provided(Req, State) ->
  {[{{<<"application">>, <<"json">>, []}, get_tags}],
    Req, State}.

get_tags(Req, State) ->
  {ok, Tags} = cn2p_catalog:get_tags(),
  {jsx:encode(Tags), Req, State}.